<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="${pageContext.request.contextPath }/admin/assets/css/bootstrap.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/style.css"/>       
        <link href="${pageContext.request.contextPath }/admin/assets/css/codemirror.css" rel="stylesheet">
        <link rel="stylesheet" href="${pageContext.request.contextPath }/admin/assets/css/ace.min.css" />
        <link rel="stylesheet" href="${pageContext.request.contextPath }/admin/assets/css/font-awesome.min.css" />
		<script src="${pageContext.request.contextPath }/admin/assets/js/jquery.min.js"></script>
		<script src="${pageContext.request.contextPath }/admin/assets/js/jquery-2.1.1.min.js"></script>
		<script src="${pageContext.request.contextPath }/admin/assets/js/bootstrap.min.js"></script>

		<script type="text/javascript">
			window.jQuery || document.write("<script src='"+${pageContext.request.contextPath }+"/admin/assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>
		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='"+${pageContext.request.contextPath }+"/admin/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="../assets/js/bootstrap.min.js"></script>
		<script src="../assets/js/typeahead-bs2.min.js"></script>
		<!-- page specific plugin scripts -->
		<script src="${pageContext.request.contextPath }/admin/assets/js/jquery.dataTables.min.js"></script>
		<script src="${pageContext.request.contextPath }/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath }/admin/js/H-ui.js"></script> 
        <script type="text/javascript" src="${pageContext.request.contextPath }/admin/js/H-ui.admin.js"></script> 
        <script src="${pageContext.request.contextPath }/admin/assets/layer/layer.js" type="text/javascript" ></script>
        <script src="${pageContext.request.contextPath }/admin/assets/laydate/laydate.js" type="text/javascript"></script>
		<title>新闻列表</title>
	</head>

	<body>
		<div class="page-content clearfix">
		    <div id="Member_Ratings">
		      <div class="d_Confirm_Order_style">
			<br>
		     <!---->
		     <div class="border clearfix">
		       <span class="l_f">
		        <button class="btn btn-xs btn-info"  data-toggle="modal" data-target="#myModal1"><i class="icon-plus"></i>添加部门</button>
		       </span>
		       <span class="r_f">共：<b>${titlesSize }</b>条</span>
		     </div>
		     <!---->
		     <div class="table_menu_list">
		       <table class="table table-striped table-bordered table-hover" id="sample-table">
				<thead>
				 <tr>
					<th width="50">ID</th>
					<th width="100">新闻标题</th>
					<th width="70">行业</th>   
					<th width="100">发布时间</th>      
					<th width="100">修改时间</th>      
					<th width="150">新闻内容</th>                    
					<th width="200">操作</th>
				</tr>
				</thead>
				<tbody>
					<s:iterator value="#request.titles">
					<tr>
			          <td>${titleId }</td>
			          <td>${titleName }</td>
			          <td>${titleIndustry }</td>
			          <td>${titleTime }</td>
			          <td>${titleUptime }</td>
			          <td>${titleText }</td>
			          <td class="td-manage">
			          <button class="btn btn-xs btn-info"  data-toggle="modal" data-target="#myModal"><i class="icon-edit bigger-120"></i></button> 
			          <a title="删除" href="deleteTitle?titleId=${titleId }"  onclick="javascript:return confirm('您确认要删除');" class="btn btn-xs btn-warning" ><i class="icon-trash  bigger-120"></i></a>
			          </td>
					</tr>
					</s:iterator>
		    	</tbody>
			</table>
		   </div>
		  </div>
		 </div>
		</div>
		 
		<!-- 添加模态框 -->
		<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
		       <div class="modal-content">
		          <div class="modal-header">
		              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		              <h4 class="modal-title">添加新闻信息</h4>
		          </div>
             	<form action="${pageContext.request.contextPath }/addTitle"  method="post">
		          <div class="modal-body">
		             <div class="planel_boxs">
		                 <div class="row"> 
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>新闻标题:</label>
		                         <input type="text" class="form-controls content" name="titleName"/>
		                     </div>
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>行&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;业:</label>
		                         <input type="text" class="form-controls identify" name="titleIndustry"/>
		                     </div>
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>发布时间:</label>
		                         <input type="text" class="form-controls identify" name="titleTime" id="title_time" />
		                     </div>
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>修改时间:</label>
		                         <input type="text" class="form-controls identify" name="titleUptime"/>
		                     </div>
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>新闻内容:</label>
		                         <textarea name="titleText" style="width:200px;height:80px;"></textarea>
		                     </div>
		                   </div>  
		            	</div>
		       		 </div>
			        <div class="modal-footer text-center">    
			           <input type="submit" class="btn btn-default btn_blue" value="添加"/>
			           <button type="button" class="btn btn-default btn_red" data-dismiss="modal">取消</button>
			        </div>
		        </form>
		      </div>
		   </div>
		</div>
		 
		<!-- 修改模态框 -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
	       <div class="modal-content">
	          <div class="modal-header">
	              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
	              <h4 class="modal-title">修改新闻信息</h4>
	          </div>
             <form action="${pageContext.request.contextPath }/updateTitle"  method="post">
	          <div class="modal-body">
	             	<div class="planel_boxs">
		                 <div class="row"> 
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>I&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;D:</label>
		                         <input type="text" class="form-controls content" name="titleId" id="title_id"/>
		                     </div>
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>新闻标题:</label>
		                         <input type="text" class="form-controls content" name="titleName" id="title_name"/>
		                     </div>
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>行&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;业:</label>
		                         <input type="text" class="form-controls identify" name="titleIndustry" id="title_industry" />
		                     </div>
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>发布时间:</label>
		                         <input type="text" class="form-controls identify" name="titleTime" id="title_time" />
		                     </div>
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>修改时间:</label>
		                         <input type="text" class="form-controls identify" name="titleUptime" id="title_uptime" />
		                     </div>
		                     <div class="row_line col-md-6 col-sm-6 col-xs-12">
		                         <label>新闻内容:</label>
		                         <textarea name="titleText" style="width:200px;height:80px;" id="title_text"></textarea>
		                     </div>
		                </div>  
		            </div>
		        </div>
		        <div class="modal-footer text-center">    
		           <input type="submit" class="btn btn-default btn_blue" onclick="javascript:return confirm('您确认要修改');" value="修改"/>
		           <button type="button" class="btn btn-default btn_red" data-dismiss="modal">取消</button>
		        </div>
	          </form>
	      </div>
	   </div>
	</div>
		
		 
	
<script>

		$("#myModal1").on('show.bs.modal', function (event){	
		      var btnThis = $(event.relatedTarget); //触发事件的按钮
		      var modal = $(this);  //当前模态框
		      var modalId = btnThis.data('id');   //解析出data-id的内容
			  setInterval(function() {
				  modal.find('#title_time').val(currentTime);
			  }, 1000);
		});
		/*用户-编辑*/
		$('#myModal').on('show.bs.modal', function (event) {
		      var btnThis = $(event.relatedTarget); //触发事件的按钮
		      var modal = $(this);  //当前模态框
		      var modalId = btnThis.data('id');   //解析出data-id的内容
		      var content = btnThis.closest('tr').find('td').eq(0).text();
		      modal.find('#title_id').val(content);     
		      var content = btnThis.closest('tr').find('td').eq(1).text();
		      modal.find('#title_name').val(content);     
		      var content = btnThis.closest('tr').find('td').eq(2).text();
		      modal.find('#title_industry').val(content);  
		      var content = btnThis.closest('tr').find('td').eq(3).text();
		      var content = btnThis.closest('tr').find('td').eq(5).text();
		      modal.find('#title_text').val(content);  
		      modal.find('#title_time').val(content);  
		      setInterval(function() {
				  modal.find('#title_uptime').val(currentTime);
			  }, 1000); 
		});
		//修改时间设置
		function currentTime() {
			var d = new Date(), str = '';
			str += d.getFullYear() + '/';
			str += d.getMonth() + 1 + '/';
			str += d.getDate() + ' ';
			str += d.getHours() + ':';
			str += d.getMinutes() + ':';
			str += d.getSeconds();
			return str;
		}
		/*用户-删除*/
		function member_del(obj,id){
			layer.confirm('确认要删除吗？',function(index){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			});
		}
		laydate({
		    elem: '#start',
		    event: 'focus' 
		});
	
	</script>
	</body>
</html>
<script type="text/javascript">
	jQuery(function($) {
			var oTable1 = $('#sample-table').dataTable( {
			"aaSorting": [[ 0, "desc" ]],//默认第几个排序
			"bStateSave": true,//状态保存
			"aoColumnDefs": [
			  {"orderable":false,"aTargets":[5,6]}// 制定列不参与排序
			] } );
			$('table th input:checkbox').on('click' , function(){
				var that = this;
				$(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function(){
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});
					
			});	
			$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
			function tooltip_placement(context, source) {
				var $source = $(source);
				var $parent = $source.closest('table')
				var off1 = $parent.offset();
				var w1 = $parent.width();
		
				var off2 = $source.offset();
				var w2 = $source.width();
		
				if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
				return 'left';
			}
		})
</script>